<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-calendar"></i> 提现申请
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="form-box" style="width: 300px;">
                <el-form ref="form" :model="form" label-width="100px">
					<el-form-item label="提现用户">
					    <div v-text="name"></div>
					</el-form-item>
					<el-form-item label="绑定银行卡">
					    <div v-text="bank_no"></div>
					</el-form-item>
					<el-form-item label="可提现额">
					    <div>{{balance}}￥</div>
					</el-form-item>
                    <el-form-item label="提现金额">
						<el-input type="number" v-model="form.price">
						  </el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit">提交申请</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
import {getBalance} from '../../api/index';
import {drawBalance} from '../../api/index';
export default {
    name: 'baseform',
    data() {
        return {
            form: {
				id:'',
                price: '',
            },
            name: '',
            balance: '0',
			bank_no:'',
        };
    },
	created() {
	    this.getData();
	},
    methods: {
		getData() {
		    getBalance().then(res => {
					this.name=res.t.name;
					this.balance=res.t.balance;
					this.bank_no=res.t.bank_no;
					this.form.id=res.t.id;
				
		    }).catch((e)=>{
			});
		},
        onSubmit() {
			if(this.form.price<=0||this.form.price==''){
				this.$message.warning('输入正确余额！');
			}else{
				if(this.balance<this.form.price){
					this.$message.warning('余额不足');
				}else{
					drawBalance(this.form).then(res => {
						if(res.code==200){
							this.$message.success('提交成功！');
							this.getData();
						}else{
							//未登入
							this.$message.error('提交失败！');
						}
					}).catch((e)=>{
						this.$message.error('网络异常！');
					});
				}
			}
        }
    }
};
</script>